<?php

if (!isset($_GET['skill']))
	$tabSkills = getSkills();

echo '<section id="skills" class="content">';
if (isset($tabSkills) && count($tabSkills) > 0) {
	foreach ($tabSkills as $group) {
		//create div with group tab
		$familiesList = "";
		foreach ($group["familyTab"] as $family) {
			if (count($family["skills"]) > 0) {
				//creation de la liste
				$htmlList = "";
				foreach ($family["skills"] as $skillData) {
					$skill = $skillData['skill'];

					$htmlList .= '<li class="aSkill">';

					if ($skillData['education'] != null || $skillData['experience'] != null) {
						$htmlList .= '<div class="skillEduExp">';
						if ($skillData['education'] != null) {
							$htmlList .= '<h3>Education</h3>';
							$htmlList .= '<ul>';
							foreach ($skillData['education'] as $education)
								$htmlList .= '<li>' . $education->name() . '</li>';
							$htmlList .= '</ul>';
						}
						if ($skillData['experience'] != null) {
							$htmlList .= '<h3>Experience</h3>';
							$htmlList .= '<ul>';
							foreach ($skillData['experience'] as $experience)
								$htmlList .= '<li>' . $experience->name() . '</li>';
							$htmlList .= '</ul>';
						}
						$htmlList .= '</div>';
					}

					if ($skill->level() != null)
						$htmlList .= '<span class="level level' . $skill->level() / 25 . '"></span>';
						
					$htmlList .= '<span class="bold">' . $skill->name() . '</span>';
					if ($skill->description() != null)
						$htmlList .= '<small class="skillDetails">' . $skill->description() . '</small>';
					$htmlList .= '</li>';
				}
				// fin de la creation de la liste

				$familiesList .= '<div class="skillsFamily">' . "\n";
				if ($family['family']->id() != -1)
					$familiesList .= '<span class="olTitle">' . $family['family']->name() . '</span>';
				$familiesList .= '	<ul>' . "\n"
						. $htmlList . "\n"
						. '	</ul>' . "\n"
						. '</div>';
			}
		}


		$groupId = str_replace(' ', '_', $group['group']->name());
        echo <<< EOSKILLS
<div id="$groupId" class="skillsGroup">
	<h1>{$group['group']->name()}</h1>
	$familiesList
</div>
EOSKILLS;
	}
}
else
	echo 'no skill';
echo '</section>';
?>